<?php
namespace Admin\Controller;
use Common\Controller\BaseController;

/**
 * 后台主页
 * Class IndexController
 * @package Admin\Controller
 */
class IndexController extends BaseController{
    protected $adminInfo;
	protected function _initialize(){
		parent::_initialize();
        $this->adminInfo = $this->checkAuth();
	}
	
	public function index(){
        //获取导航
		$this->showView();
	}

    /**
     * 获取导航菜单
     */
    public function getNavList(){
        $adminInfo = getAdminInfo();
        if ($adminInfo['fk_role_id'] != 1){
            $map['pk_id'] = array('in',explode(',', $adminInfo['menu_auth']));
        }
        $map['pid'] = 0;
        $map['is_hidden'] = 0;
        $field = 'pk_id,name,control';
        $rows = $this->getRows('sys_menu', $map ,$field);
        $this->data['rows'] = $rows;
        $this->rtnResult(0);
    }

    /**
     * 获取菜单列表
     * @param $pk_id 上级菜单ID
     */
    public function getMenuList($pk_id){
        $adminInfo = getAdminInfo();
        if ($adminInfo['fk_role_id'] != 1){
            $map['pk_id'] = array('in',explode(',', $adminInfo['menu_auth']));
        }
        $map['is_hidden'] = 0;
        $map['status'] = 0;
        $field = 'pk_id,pid,sort,name,control';
        $rows = $this->getRows('sys_menu', $map ,$field , 'sort DESC');
        if($rows){
            $rows = list_to_tree($rows);
            foreach ($rows as $key=>$value){
                if ($value['pk_id'] == $pk_id){
                    $rows = $value['_child'];
                    break;
                }
            }
        }
        $this->data['rows'] = $rows;
        $this->rtnResult(0);
    }

	public function test(){
        $root_path = substr(__FILE__,0,strpos(__FILE__,'Application'));
        $file = $root_path.'ThinkPHP/Library/Vendor/Weixin/wxpay/example/jsapi.php';
        require $file;


        dump(jsPay(('')));




        die;
		$model = new AdminModel();
		$model->aaa();
	}
}

